<template>
    <div class="tree-content" id="tree">
      <el-tree
        :data="layerData"
        show-checkbox
        :props="defaultProps"
        @check-change="handleCheckChange"
        @node-click="handleRowClick"
        ref="mytree"
      >
      <template #default="{node,data}">
        <span class="custom-tree-node">
          <span  v-if="data.count">
               <span v-if="data.children.length ==0">
              <img :src="'/data/images/icon/'+ node.label+'.png'" alt="" style="width:15px;height:15px;vertical-align:middle;margin-right:10px;">
           </span>
          </span>
          <span>{{ node.label }}</span>
          <span v-if="data.count">(</span>
          <span v-if="data.count">{{ data.count }}</span>
          <span v-if="data.count">)</span>
        </span>
      </template>
      </el-tree>
    </div>
</template>

<script>
export default {
    props:["msg"],
    data(){
        return{
            defaultProps: {
             children: "children",
             label: "label",
            },  
            model:[],
            layerData:[],
            childrenData:[]
        }
    },
    watch:{
      msg(newval,oldval){
        // console.log(newval)
          // debugger
        this.layerData = newval
        // console.log(this.layerData)
      }
    },
    methods:{
        handleCheckChange(data, checked){
          this.$emit("treedata",data,checked)
        },
        handleRowClick(data, node) {
            node.checked = !(node.checked)
        },
        
    },
    mounted(){
      this.$refs['mytree'].$forceUpdate()
    }
}
</script>
<style scoped lang="stylus">
/deep/ .el-tree {
  width: 100%;
  height: calc(100% - 6px);
  font-size: 0.18rem;
  margin: 0.2rem 0;
  background: none;
  color: #fff;
  // position: relative;
  overflow: auto;

  .el-checkbox__inner {
    border-radius: 0 !important;
    background: none;
    margin: 0 15px 0 5px;
  }
}

/deep/ .el-tree .el-tree-node__content {
  background: rgba(16, 34, 67, 0.5);
  height: 30px;
  margin-bottom: 5px;

  .is-disabled + span {
    color: #fff;
  }

  /deep/ .custom-tree-node {
    position: relative;
    width: calc(100% - 70px);
    overflow: hidden;
    .txt {
      display: inline-block;
      width: 75%;
      overflow: hidden;
      text-overflow: ellipsis;
      vertical-align: middle;
    }

    /deep/ image{
        vertical-align: middle;
        width: 24px;
        height: 24px;
      }
  }
}

/deep/ .el-tree .is-disabled + span {
  color: #fff;
}

/deep/ .el-tree .el-tree-node__content:hover {
  background-color: #b67d10;
}

/deep/ .el-tree .el-tree-node:focus > .el-tree-node__content {
  background-color: #b67d10;
}

/deep/ .el-tree .el-menu-item:focus, /deep/ .el-tree .el-menu-item:hover {
  background: none !important;
}

/deep/ .el-tree .el-menu-item * {
  vertical-align: baseline !important;
}

/deep/ .el-tree .el-tooltip {
  padding: 0 !important;
}

/deep/ .el-tree .custom-tree-node:hover .tool {
  display: inline-block;
  /* visibility: visible; */
}

/deep/ ::-webkit-scrollbar {
  /* 滚动条整体样式 */
  width: 4px;
  /* 高宽分别对应横竖滚动条的尺寸 */
  height: 0;
}

/deep/ ::-webkit-scrollbar-thumb {
  /* 滚动条里面小方块 */
  border-radius: 5px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: #2fd5ff;
  scrollbar-arrow-color: red;
}

/deep/ ::-webkit-scrollbar-track {
  /* 滚动条里面轨道 */
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
</style>
<style lang="stylus" scoped>
@media (max-width: 2880px) {
  .tree-content {
    width: vw(260);
    height:vh(600);
    // position: absolute;
    // top: vh(0);
    // right: vw(45);
    background:rgba(20, 42, 73,0.7)
  }
}
</style>
<style lang="stylus" scoped>
@media (min-width: 3000px) {
  .tree-content {
    width: vw(230);
    height:vh(600);
    // position: absolute;
    // top: vh(0);
    // right: vw(45);
    background:rgba(20, 42, 73,0.7)
  }
}
</style>